<!-- 用户管理 -->
<!-- 角色管理 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <div class="n-card-header__main pm10">
      用户管理
    </div>
    <div>
      <dxtable :headBtn="headBtn" :dataJson="dataJson" :portUrl="portUrl" :qx="qx" ref="databale" :formJson="formJson">
      </dxtable>

    </div>
  </div>
</template>
<script lang='ts' setup>
import dxtable from "../../../components/util/dxtable.vue";
import sort from "../../../components/util/sort.vue";
import { dxget, dxpost, qurl, hf } from "../../../util/index";
import { h, ref, reactive } from "vue";
const props = defineProps({
  pup: { type: String },
});

let headBtn = [];
const zdList = ref()
const databale = ref();
const mouldRoleList = ref([])
const dicProcessesListwl = ref([])
const initeer = () => {
  databale.value.initDataExpose();
};
const emit = defineEmits(["callBack"]);
// 获取角色列表
const getRolList = async () => {
  const { data }: any = await dxget("hhscdd/hhbase/mouldRoleList")
  dataJson[2].options = [
    {
      label:"全部",
      value:""
    },
    ...data
  ]
  formJson[0].options = data
  dataJson[1].options = [
    {
      label:"全部",
      value:""
    },
    ...data
  ]
  mouldRoleList.value = data
}
// 获取工序列表
const getdicProcessesList = async () => {
  const { data }: any = await dxget("hhscdd/hhbase/dicProcessesList")
  console.log(formJson);
  console.log('666661121');
   formJson[5].options = data
  dataJson[6].options = [
    {
      label:"全部",
      value:""
    },
    ...data
  ]
  dicProcessesListwl.value = data
  console.log(dataJson);

  console.log('222288888888');
}



getRolList()
getdicProcessesList()
let dataJson = reactive([

  {
    title: "ID",
    key: "id",
    width: 70,
  },
  {
    title: "手机号",
    key: "phone",
    width: 100,
  },


  {
    title: "角色名称",
    search: true, // 是否在搜索栏展示
    key: "roles",
    type: "select",
    options: [],
    render(row) {
      const qxList =[]
      if (row.roles) {
        // console.log(row.roles);
        mouldRoleList.value.map(a => {
  
         try{
          row.roles.map(b=>{
            if(a.value==b){
              qxList.push(a.label)
            }
          })
         }catch(e){
            // console.log(e)
         }
       
        })
      }
     try{
      row.roles = row.roles.split(",")
     }catch(e){

     }
      return qxList.join(",")
    }

  },
  {
    title: "用户账号",
    search: true, // 是否在搜索栏展示
    key: "user_account",
  }, 
  {
    title: "用户密码",
    key: "password",
    type: "input",
    width:80,
  },
  {
    title: "姓名",
    search: true, // 是否在搜索栏展示
    key: "real_name",
  }, 
  
  
  {
    title: "工序",
    key: "process",
    search: true, // 是否在搜索栏展示
    type: "select",
    options: [],
    render(row){
      if(row.process){
       let jslabel = ""
       try{
         jslabel = '--'+ dicProcessesListwl.value.filter(a=>a.value==row.process)[0].label
       }catch(e){

       }
        return row.process +jslabel
      }else{
        return '--'
      }
      
    }
  },
  {
    title: "排序",
    width: 100,
    render(row) {
      row.databaseName = "mould_user";
      row.tb="mysql2"
      return h(sort, {
        row,
        onCallBack: () => {
          initeer();
        },
      });
    },
  },
]);
let portUrl = "hhscdd/mould_user";
const qx = {
  DeletePermissionID: "hhuserListdel", //删除
  EditPermissionIdentifier: "hhuserListbj", // 编辑
  NewPermissionIdentifier: "hhuserListxz", // 新建
  ViewPermissionID: "hhuserListck", // 查看
};



let formJson = reactive([
  {
    title: "角色名称",
    key: "roles",
    type: "select",
    options: [],
    multiple: true,
    xzshow:true,
    span: 24
  }, 
    {
      title: "手机号",
    key: "phone",
    type: "input",
    span: 12
  },
  {
    title: "用户账号",
    key: "user_account",
    type: "input",
    required: true,
  },
  {
    title: "用户密码",
    key: "password",
    type: "input",
    required: true,
  },
  {
    title: "姓名",
    key: "real_name",
    type: "input",
    required: true,
  },
  {
    title: "负责工序",
    key: "process",
    type: "select",
    options: [],
    xzshow:true,
  },





])





</script>
  
  